<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%@ include file="./../../header_inc.jsp"%>
</head>
<script type="text/javascript">
//右侧菜单
function btnSave_click() {
	$.ajax(
			{
				url : '${saveUrl}', //server script to process data
				type : 'POST',
				data : formData,
				async: false,
				cache : false,
				contentType : false,
				processData : false,
				dataType:'json',//请求的数据类型
				xhr : function() { // custom xhr
					myXhr = $.ajaxSettings.xhr();
					if (myXhr.upload) { // if upload property exists
						myXhr.upload.addEventListener('progress',
								progressHandlingFunction, false); // progressbar
					}
					return myXhr;

				},
				//Ajax events
				success : function(data) {
		               if(data.success == 0 )
		               {
		            	   fun_ret = true;
		               }
		               else
		               {
		            	   top.Ext.Msg.alert("返回提示",data.msg);
		               }
		           },
				error : errorHandler = function(data) {
					$.messager.alert("错误提示", data.msg);
					return false;
				}
			});	
}
function progressHandlingFunction(e) {
	if (e.lengthComputable) {
		$('progress').attr({
			value : e.loaded,
			max : e.total
		});
	}
}
function back() {
	var ids = [];
	var rows = $('#dgb').datagrid('getSelections');
	var len = $('#dgb').datagrid('getSelections').length; 
	for(var i=0; i<rows.length; i++){
		ids.push(rows[i].depId);
	}
    if(!len)
    {
        $.messager.alert("提示","请选择要恢复的数据！");
    }
    else
    {
        $.messager.confirm("恢复确认","是否要恢复你选择的数据？",function(conf){
            if(conf)
            {
                var url = "${ctx}/manage/sysDepartment/back?depIds="+ids;
                $.getJSON(url, function(json){
                    if(json.success==0)
                    {
                    	
                    	$('#dgb').datagrid('uncheckAll');
                        $('#dgb').datagrid('reload');
                    }
                    else
                    {
                        showErrMsg(json);
                    }
                });
            }                                       
        });
    }
}
//右侧菜单
function showStatus(status) {
	if(status==0){
		return "<font color='blue'>"+"正常"+"</font>";
	}
	return "<font color='red'>"+"禁用"+"</font>";
}
</script>
<body>

<div id="toolbar" style="height: auto">
	<a href="javascript:void(0)" class="easyui-linkbutton"
		data-options="iconCls:'icon-undo',plain:true" onclick="back()">回退</a>
</div>
<table id="dgb" border="2" class="easyui-datagrid" title="部门回收站" fit="true" style="width: 800px; height: 250px"
		data-options="rownumbers:true,singleSelect:false,url:'/manage/sysDepartment/dataGridBack',method:'get',toolbar:'#toolbar',fit:true,
		showFooter:false,pagination:true,idField:'depId'">
			<thead>
				<tr>
					<th data-options="field:'',width:60,checkbox:true">全选</th>
					<th data-options="field:'depId',width:80,align:'center'">编号</th>
					<th data-options="field:'depName',width:80,align:'center'">部门名称</th>
					<th data-options="field:'depIcon',width:60,align:'center'">部门图标</th>
					<th data-options="field:'status',width:100,align:'center',formatter:showStatus">状态</th>
					
				</tr>
			</thead>
</table>
</body>
</html>